home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Graphic Gems I, II & III (C_C++) / Graphics Gems C Code.sea / GemsI / Src / 2DClip / line.h < prev    next >
Text File  |  1992-06-16  |  2KB  |  82 lines

  1.  
  2. /*
  3. Two-Dimensional Clipping: A Vector Based Approach
  4. by Hans Spoelder and Fons Ullings
  5. from "Graphics Gems", Academic Press, 1990
  6. */
  7.  
  8.  
  9. /*
  10.  * file line.h
  11.  *     contains major definitions for the clipping routines
  12.  *
  13.  */
  14. #define    NFAC        10        /* discrete measure    */
  15.     
  16. #define    SCALE        (1 << NFAC)    /* 1024 points/cm    */
  17. #define    TO_INT(X)    ((int)((X)*SCALE))
  18. #define    TO_FLT(X)    (((float)(X))/SCALE)
  19.  
  20. #define    COINCIDE        1        /* what do the lines do    */
  21. #define    PARALLEL        2
  22. #define    CROSS        3
  23. #define    NO_CROSS        4
  24.  
  25. #define    STD            0        /* crossing types    */
  26. #define    DELAY        1
  27.  
  28. #define    CLIP_NORMAL    1
  29.  
  30. typedef    struct    {        /* holds a point    */
  31.     long    _x;            /* holds x coordinate    */
  32.     long    _y;            /* holds y coordinate    */
  33. } POINT;
  34.  
  35. typedef    struct    {        /* holds a cross point    */
  36.     POINT    _p;            /* holds the solution    */
  37.     short    _type;        /* more information    */
  38. } CLIST;
  39.     
  40. struct    segment    {            /* holds a segment    */
  41.     POINT    _from;            /* start coordinates    */
  42.     POINT    _to;            /* stop coordinates    */
  43.     struct    segment    *_next;
  44.     struct    segment    *_prev;
  45. };
  46.  
  47.  
  48. #define    SEGMENT        struct segment
  49.  
  50. struct    contour {            /* holds a contour    */
  51.     short    _no;            /* contour counter    */
  52.     short    _status;            /* holds information    */
  53.     short    _cnt;            /* number of elements    */
  54.     SEGMENT    *_s;            /* the segments        */
  55.     struct    contour *_next;    /* linked list        */
  56.     long    _minx;            /* coordinates of box    */
  57.     long    _miny;
  58.     long    _maxx;
  59.     long    _maxy;
  60. };
  61.  
  62. #define    CONTOUR        struct contour
  63.  
  64. #define    ACTIVE        01        /* polygon attributes    */
  65. #define    NORMAL        02
  66.  
  67. #define    SET_ON(p)    ((p)->_status |=  ACTIVE)
  68. #define    SET_NORMAL(p)    ((p)->_status |= NORMAL)
  69.  
  70. #define    SET_OFF(p)    ((p)->_status &= ~ACTIVE)
  71. #define    SET_INVERSE(p)    ((p)->_status &= ~NORMAL)
  72.  
  73. #define    IS_ON(p)    ((p)->_status & ACTIVE)
  74. #define    IS_NORMAL(p)    ((p)->_status & NORMAL)
  75.  
  76. extern    CONTOUR    *CL;
  77.  
  78. CONTOUR    *get_contour_ptr();
  79.  
  80. extern    short    C_COUNT;
  81.  
  82.